import {Component, OnInit, Input} from '@angular/core';
import {Storage} from '@ionic/storage';
import {NavController, ActionSheetController, AlertController} from 'ionic-angular';
import {MarketingHomeService} from "./home.service";
import {DomSanitizer} from '@angular/platform-browser';
import _ from "lodash";
import * as moment from "moment";
import {Common} from "../../../../providers/common";

@Component({
  selector: "page-irp-panoramagram-main",
  templateUrl: 'main.html'
})
export class IrpPanoramagramMainPage {
  moa_page_name: any = "page-irp-panoramagram-main";
  moa_page_explain: any = "研究员空间";

  pageData = {
    divideWork: [
      {
        name: "宏观",
        expand: false,
        list: [
          {
            name: "孙迪"
          }
        ]
      },
      {
        name: "消费",
        expand: false,
        list: [
          {
            name: "孙迪"
          }
        ]
      },
      {
        name: "TMT",
        expand: false,
        list: [
          {
            name: "孙迪"
          }
        ]
      },
      {
        name: "周期",
        expand: false,
        list: [
          {
            name: "孙迪"
          }
        ]
      },
      {
        name: "制造业",
        expand: false,
        list: [
          {
            name: "孙迪"
          }
        ]
      },
      {
        name: "海外",
        expand: false,
        list: [
          {
            name: "孙迪"
          }
        ]
      },
      {
        name: "其他",
        expand: false,
        list: [
          {
            name: "孙迪"
          }
        ]
      }
    ]
  };

  constructor(public navCtrl: NavController,
              public alertCtrl: AlertController,
              public storage: Storage,
              public common: Common) {

  }

  ionViewDidEnter() {
    this.initMacroStrategiesGrid();
  }

  /**
   * 展开/收起 人员分组
   * @param item
   */
  expandDivideWork(item) {
    item.expand = !item.expand;
  }

  /**
   * 跳转到人员穴
   * @param item
   */
  goToPeopleSpace(item) {

  }

  initMacroStrategiesGrid() {
    console.log(moment().daysInMonth());
    let categories = [];
    let days = moment().daysInMonth();
    for(let i = 1; i <= days; i++) {
      categories.push(moment({ y    :2017, M     :10, d   :1}));
    }

    window["Highcharts"].chart('macroStrategies', {
      chart: {
        type: 'line'
      },
      title: {
        text: null
      },
      subtitle: {
        text: null
      },
      xAxis: {
        categories: ['2017-01-01', '2017-02-01', '2017-03-01',
          '2017-04-01', '2017-05-01', '2017-06-01', '2017-07-01',
          '2017-08-01', '2017-09-01', '2017-10-01', '2017-11-01', '2017-12-01']
      },
      yAxis: [{
        title: {
          text: '研究部宏观策略',
          style: {
            color: "#fc7a00"
          }
        }
      }, {
        title: {
          text: '沪深300指数',
          style: {
            color: "#7cb5ec"
          }
        },
        opposite: true,
        labels: {
          format: '{value:.,0f}',
        }
      }],
      plotOptions: {
        line: {
          dataLabels: {
            enabled: true
          },
          enableMouseTracking: false
        }
      },
      series: [{
        name: '研究部宏观策略',
        data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6],
        color: "#fc7a00"
      }, {
        name: '沪深300指数',
        data: [4.5, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8],
        yAxis: 1
      }]
    });
  }

}

